package com.platform.modules.report.service;

import com.platform.common.utils.MapUtil;
import com.platform.modules.report.dao.PrjReportDao;
import com.platform.modules.report.dao.QlyInsReportDao;
import com.platform.modules.report.dto.BaseQueryDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class QlyInsReportService{



    @Autowired
    QlyInsReportDao qlyInsReportDao;


    public Integer qlyInsCount(BaseQueryDTO baseQueryDTO, Map<String,Object> extra) {
        return qlyInsReportDao.qlyInsCount(baseQueryDTO, extra);
    }

    public Integer queCount(BaseQueryDTO baseQueryDTO, Map<String,Object> extra) {
        return qlyInsReportDao.queCount(baseQueryDTO, extra);
    }


    public Map<String, Object> qlyInsCountGroupByCity(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> qlyInsCountList = qlyInsReportDao.qlyInsCountGroupByCity(baseQueryDTO);
        return MapUtil.flat(qlyInsCountList,"CITY_NUM","COUNT");
    }

    public Map<String, Object> overdueCountGroupByCity(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> qlyInsCountList = qlyInsReportDao.overdueCountGroupByCity(baseQueryDTO);
        return MapUtil.flat(qlyInsCountList,"CITY_NUM","COUNT");
    }

    public Map<String, Object> avgOverdueDaysGroupByCity(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> qlyInsCountList = qlyInsReportDao.avgOverdueDaysGroupByCity(baseQueryDTO);
        return MapUtil.flat(qlyInsCountList,"CITY_NUM","AVG_OVERDUE_DAYS");
    }

    public Map<String, Object> qlyInsCountGroupByStatus(BaseQueryDTO baseQueryDTO) {
        List<Map<String, Object>> queCountList = qlyInsReportDao.qlyInsCountGroupByStatus(baseQueryDTO);
        return MapUtil.flat(queCountList,"QUE_STATUS","COUNT");
    }

    public Map<String, Object> queCountGroupByLevel(BaseQueryDTO baseQueryDTO) {
        List<Map<String, Object>> queCountList = qlyInsReportDao.queCountGroupByLevel(baseQueryDTO);
        return MapUtil.flat(queCountList,"QUE_LEVEL","COUNT");
    }

    public Map<String, Object> queCountGroupByType(BaseQueryDTO baseQueryDTO) {
        List<Map<String, Object>> queCountList = qlyInsReportDao.queCountGroupByType(baseQueryDTO);
        return MapUtil.flat(queCountList,"QUE_TYPE","COUNT");
    }
}
